package com.shuoyue.ycgk.ui.course.info;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

import androidx.core.widget.NestedScrollView;

import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.utils.MyRichTextHelper;
import com.zzhoujay.richtext.RichText;

import butterknife.BindView;

public class FragmentCourseInfo extends BaseCourseInfoFragment {
    String info;
    @BindView(R.id.info)
    TextView textView;
    @BindView(R.id.scrollView)
    NestedScrollView scrollView;

    public static FragmentCourseInfo newInstance(String info) {
        FragmentCourseInfo fragment = new FragmentCourseInfo();
        Bundle args = new Bundle();
        args.putString("info", info);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void initParams(Bundle bundle) {
        info = bundle.getString("info");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_course_info;
    }

    @Override
    protected void initView() {
        if (!TextUtils.isEmpty(info))
        MyRichTextHelper.showRich(mContext,info,textView);


        scrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
            if (scrollY == 0) {
                isScrollAtTop = true;
            } else {
                isScrollAtTop = false;
            }
        });
    }

    @Override
    public String getTitle() {
        return "课程介绍";
    }
}
